package com.zhj.structure.tree.utils;

/**
 * @PackageName:com.zhj.structure.tree.utils
 * @ClassName:ArrayBinaryTree
 * @auter: 朱慧杰
 * @date:2020/8/10 0010 15:44
 **/
public class ArrayBinaryTree {

    // 顺序二叉树

    private int[] data;

    public ArrayBinaryTree(int[] data) {
        this.data = data;
    }

    public void frontShow() {
        frontShow(0);
    }

    public void frontShow(int index) {
        if (data == null || data.length == 0) {
            System.out.println("空树");
            return;
        }
        System.out.print(data[index] + "\t");
        if (2*index+1 < data.length) {
            frontShow(2*index+1);
        }
        if (2*index+2 < data.length) {
            frontShow(2*index+2);
        }
    }

}